<?php
/**
 * Created by PhpStorm.
 * User: 38339
 * Date: 2021-05-21
 * Time: 16:49
 */

namespace app\common\model\mysql;
use think\Model;

class YwProjectSubmitRecord extends Model
{
    protected $name = 'yw_project_submit_record';

    // 设置字段信息
    protected $schema = [
        //定义字段开始
        'id'          => 'int',//主键
        'admin_id'        => 'int', //提交人
        'zip_str'      => 'string',    //压缩文件地址
        'create_time' => 'datetime',    //创建时间
        'is_check'    => 'int',   //是否检测
        'check_time'  => 'datetime', //检测时间
        'remark'        => 'string',  //备注
        'check_result' => 'string', //检测结果
        //定义字段结束
    ];

    /**
     * @param $models
     * @return array
     */
    public static function fillModels($models)
    {
        $list = [];
        foreach ($models as $model) {
            $listItem = static::fillModel($model);
            $list[] = $listItem;
        }
        return $list;
    }

    public static function fillModel($model)
    {

        $data = [];
        $data['id'] = $model['id'];
        $data['admin_id'] = $model['admin_id'];
        $data['zip_str'] = $model['zip_str'];
        $data['create_time'] = $model['create_time'];
        $data['is_check'] = $model['is_check'];
        $data['check_result'] = $model['check_result'];
        $data['check_time'] = $model['check_time'];
        $data['remark'] = $model['remark'];
        return $data;
    }


    /*
     * 获取列表
     */
    public static function getList($where,$limit_start,$page_size){
        $lists =  self::where($where)->order('id','desc')->limit($limit_start,$page_size)->select();
        return self::fillModels($lists);
    }

    /*
     * 获取总数据条数
     */
    public static function getCount($where){
        return self::where($where)->count();
    }

    /*
     * 获取单条数据
     */
    public static function getOne($where){
        return self::where($where)->find();
    }

}